<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- designer-manual.qdoc -->
  <title>保存、预览、打印窗体 | Qt Designer 手册</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtdesigner-manual.html">Qt Designer 手册</a></td><td >保存、预览、打印窗体</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtdesigner-manual.html">Qt 5.14.2 参考文档</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="designer-layouts.html" />
  <link rel="next" href="designer-buddy-mode.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="designer-layouts.html">使用布局</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="designer-buddy-mode.html">伙伴编辑模式</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#viewing-the-form-s-code">查看窗体代码</a></li>
<li class="level1"><a href="#saving-and-printing-the-form">保存和打印窗体</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">保存、预览、打印窗体</h1>
<span class="subtitle"></span>
<!-- $$$designer-preview.html-description -->
<div class="descr"> <a name="details"></a>
<p>虽然 <i>Qt Designer</i> 的窗体是正在编辑的组件的准确表示，但在编辑时预览最终外观是有用的。这个特性可以通过打开 <b>窗体(O)</b> 并选择 <b>预览(P)</b> 来激活，或者在窗体中按 <b>Ctrl+R</b> 来激活。</p>
<p class="centerAlign"><img src="images/designer-dialog-preview.png" alt="" /></p><p>预览准确地显示了最终组件在应用程序中使用时的样子。</p>
<p>自从Qt 4.4以来，可以预览应用了各种皮肤的窗体 —— 默认皮肤、用Qt样式表创建的皮肤或设备皮肤。在应用程序中调用 <code>QApplication::setStyleSheet()</code> 模拟该特性的效果。</p>
<p>要用皮肤预览窗体，请打开 <b>设置(S)</b> 菜单并选择 <b>属性...</b></p>
<p>您将看到如下对话框:</p>
<p class="centerAlign"><img src="images/designer-preview-style.png" alt="" /></p><p>必须选中 <b>打印/预览配置</b> 复选框才能激活皮肤预览。您可以从 <b>风格</b> 下拉框中选择提供的样式。</p>
<p class="centerAlign"><img src="images/designer-preview-style-selection.png" alt="" /></p><p>或者，您可以预览使用Qt样式表创建的自定义样式表。下图显示了Qt样式表语法的示例和相应的输出。</p>
<p class="centerAlign"><img src="images/designer-preview-stylesheet.png" alt="" /></p><p>另一个选项是使用设备皮肤预览窗体。在 <i>Qt Designer</i> 中有一个通用设备皮肤列表，但您也可以在其下点 <b>Browse...</b> 选择使用其他QVFB皮肤。</p>
<p class="centerAlign"><img src="images/designer-preview-deviceskin-selection.png" alt="" /></p><a name="viewing-the-form-s-code"></a>
<h2 id="viewing-the-form-s-code">查看窗体代码</h2>
<p>从Qt 4.4开始，可以查看 <i>Qt Designer</i> 窗体的用户界面编译器(uic)生成的代码。</p>
<p class="centerAlign"><img src="images/designer-form-viewcode.png" alt="" /></p><p>选择 <b>View Code..&#x2e;</b> 从 <b>窗体(O)</b> 菜单中，将显示一个带有生成代码的对话框。下面的屏幕截图是 <code>uic</code> 生成的代码示例。</p>
<p class="centerAlign"><img src="images/designer-code-viewer.png" alt="" /></p><a name="saving-and-printing-the-form"></a>
<h2 id="saving-and-printing-the-form">保存和打印窗体</h2>
<p>在 <i>Qt Designer</i> 中创建的窗体可以保存为图像或打印。</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/designer-file-menu.png" alt="" /></td><td ><b>保存窗体</b><p>若要将窗体保存为图像，请选择 <b>保存图像(I)...</b> 。文件将以 <code>.png</code> 格式保存。</p>
<p><b>打印窗体</b></p>
<p>若要打印窗体，请选择 <b>打印(P)...</b> 。</p>
</td></tr>
</table></div>
</div>
<!-- @@@designer-preview.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="designer-layouts.html">使用布局</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="designer-buddy-mode.html">伙伴编辑模式</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
